package com.cddx.logistics.controller;

import com.cddx.logistics.domain.vo.WireStatisticsVo;
import com.cddx.logistics.service.WireStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/statistics/wire")
public class WireStatisticsController {

    @Autowired
    private WireStatisticsService wireStatisticsService;

    @GetMapping("/monthly")
    public List<WireStatisticsVo> getMonthlyStatistics(
            @RequestParam(value = "startDate", required = false)
            @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,

            @RequestParam(value = "endDate", required = false)
            @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,

            @RequestParam(value = "specifications", required = false)
            String specifications) {

        return wireStatisticsService.getWireStatisticsByCondition(
                startDate, endDate, specifications
        );
    }
    @GetMapping("/names")
    public List<String> getWireNames() {
        return wireStatisticsService.getWireNames();
    }
}
